<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
       
      <meta name="keywords" content="陈亚东 cyd 凤舞神者" />
       
      <meta name="description" content="85年的精神小伙,不是神者有点神经,水尿吧汤 " />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title> 风舞神者</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      
<section class="cover">
    
      
      <a class="forkMe" href="https://github.com/Shen-Yu/hexo-theme-ayer"
        target="_blank"><img width="149" height="149" src="/images/forkme.png"
          class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a>
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover1.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">风舞神者</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.staticfile.org/typed.js/2.0.12/typed.min.js"></script>


<!-- Subtitle -->

  <script>
    try {
      var typed = new Typed("#subtitle", {
        strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
        startDelay: 0,
        typeSpeed: 200,
        loop: true,
        backSpeed: 100,
        showCursor: true
      });
    } catch (err) {
      console.log(err)
    }
  </script>
  
<div id="main">
  <section class="outer">
  
  <ul class="ads">
    
        <li>
            <a target="_blank" rel="noopener" href="https://curl.qcloud.com/kvO7hb43">
                <img src="https://pic.imgdb.cn/item/62174b452ab3f51d912a5ccc.jpg" width="300" alt="云服务器限时秒杀">
            </a>
        </li>
    
        <li>
            <a target="_blank" rel="noopener" href="https://www.vultr.com/?ref=8630075">
                <img src="https://pic.imgdb.cn/item/62174b452ab3f51d912a5cd7.png" width="300" alt="vultr优惠vps">
            </a>
        </li>
    
</ul>
  
  
  

<div class="notice" style="margin-top:50px">
    <i class="ri-heart-fill"></i>
    <div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
    fetch('https://v1.hitokoto.cn')
        .then(response => response.json())
        .then(data => {
            document.getElementById("broad").innerHTML = data.hitokoto;
        })
        .catch(console.error)
</script>

<style>
    .notice {
        padding: 20px;
        border: 1px dashed #e6e6e6;
        color: #969696;
        position: relative;
        display: inline-block;
        width: 100%;
        background: #fbfbfb50;
        border-radius: 10px;
    }

    .notice i {
        float: left;
        color: #999;
        font-size: 16px;
        padding-right: 10px;
        vertical-align: middle;
        margin-top: -2px;
    }

    .notice-content {
        display: initial;
        vertical-align: middle;
    }
</style>
  
  <article class="articles">
    
    
    
    
    <article
  id="post-markdown语法"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/09/28/markdown%E8%AF%AD%E6%B3%95/"
    >markdown语法</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/09/28/markdown%E8%AF%AD%E6%B3%95/" class="article-date">
  <time datetime="2023-09-28T07:28:55.000Z" itemprop="datePublished">2023-09-28</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="1-标题"><a href="#1-标题" class="headerlink" title="1 标题"></a>1 标题</h1><p>使用 # 号标记</p>
<p>使用 <strong>#</strong> 号可表示 1-6 级标题，一级标题对应一个 <strong>#</strong> 号，二级标题对应两个 <strong>#</strong> 号，以此类推。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 一级标题</span><br><span class="line">## 二级标题</span><br><span class="line">### 三级标题</span><br><span class="line">#### 四级标题</span><br><span class="line">##### 五级标题</span><br><span class="line">###### 六级标题</span><br></pre></td></tr></table></figure>

<h1 id="我是一级标题"><a href="#我是一级标题" class="headerlink" title="我是一级标题"></a>我是一级标题</h1><h2 id="我是二级标题"><a href="#我是二级标题" class="headerlink" title="我是二级标题"></a>我是二级标题</h2><h3 id="我是三级标题"><a href="#我是三级标题" class="headerlink" title="我是三级标题"></a>我是三级标题</h3><h1 id="2-段落"><a href="#2-段落" class="headerlink" title="2 段落"></a>2 段落</h1><h2 id="2-1-段落"><a href="#2-1-段落" class="headerlink" title="2.1 段落"></a>2.1 段落</h2><p>Markdown 段落没有特殊的格式，直接编写文字就好，<strong>段落的换行是使用两个以上空格加上回车</strong>。</p>
<p>我是段落</p>
<h2 id="2-2-字体"><a href="#2-2-字体" class="headerlink" title="2.2 字体"></a>2.2 字体</h2><p>Markdown 可以使用以下几种字体：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">*斜体文本*</span><br><span class="line">_斜体文本_</span><br><span class="line">**粗体文本**</span><br><span class="line">__粗体文本__</span><br><span class="line">***粗斜体文本***</span><br><span class="line">___粗斜体文本___</span><br></pre></td></tr></table></figure>



<h2 id="2-3-分隔线"><a href="#2-3-分隔线" class="headerlink" title="2.3 分隔线"></a>2.3 分隔线</h2><p>你可以在一行中用三个以上的星号、减号、底线来建立一个分隔线，行内不能有其他东西。你也可以在星号或是减号中间插入空格。下面每种写法都可以建立分隔线：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">***</span><br><span class="line"></span><br><span class="line">* * *</span><br><span class="line"></span><br><span class="line">*****</span><br><span class="line"></span><br><span class="line">- - -</span><br><span class="line"></span><br><span class="line">----------</span><br></pre></td></tr></table></figure>

<p>效果如下:</p>
<hr>
<hr>
<hr>
<hr>
<h2 id="2-4-删除线"><a href="#2-4-删除线" class="headerlink" title="2.4 删除线"></a>2.4 删除线</h2><p>如果段落上的文字要添加删除线，只需要在文字的两端加上两个波浪线 <strong>~~</strong> 即可，实例如下：</p>
<p><del>我是删除线</del></p>
<h2 id="2-5-下划线"><a href="#2-5-下划线" class="headerlink" title="2.5 下划线"></a>2.5 下划线</h2><p>下划线可以通过 HTML 的 <strong><u></strong> 标签来实现：</p>
<p><u>删除线在此</u></p>
<h2 id="2-6-脚注"><a href="#2-6-脚注" class="headerlink" title="2.6 脚注"></a>2.6 脚注</h2><p>脚注是对文本的补充说明。</p>
<p>Markdown 脚注的格式如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[^要注明的文本]</span><br></pre></td></tr></table></figure>

<p>以下实例演示了脚注的用法：</p>
<p>创建脚注格式类似这样 <a href="%E6%88%91%E7%9A%84%E6%9C%AA%E6%9D%A5%E4%B8%8D%E6%98%AF%E6%A2%A6%EF%BC%81%EF%BC%81%EF%BC%81">^我是脚注</a>。</p>
<h1 id="3-列表"><a href="#3-列表" class="headerlink" title="3 列表"></a>3 列表</h1><p>Markdown 支持有序列表和无序列表。</p>
<h2 id="3-1-无序列表"><a href="#3-1-无序列表" class="headerlink" title="3.1 无序列表"></a>3.1 无序列表</h2><p>使用星号(<em>****)、加号(<strong>+</strong>)或是减号(</em>*-**)作为列表标记，这些标记后面要添加一个空格，然后再填写内容：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">* 第一项</span><br><span class="line">* 第二项</span><br><span class="line">* 第三项</span><br><span class="line"></span><br><span class="line">+ 第一项</span><br><span class="line">+ 第二项</span><br><span class="line">+ 第三项</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">- 第一项</span><br><span class="line">- 第二项</span><br><span class="line">- 第三项</span><br></pre></td></tr></table></figure>



<ul>
<li>第一项</li>
<li>第二项</li>
<li>第三项</li>
</ul>
<ul>
<li>第一项</li>
<li>第二项</li>
<li>第三项</li>
</ul>
<ul>
<li>第一项</li>
<li>第二项</li>
<li>第三项</li>
</ul>
<h2 id="3-2-有序列表"><a href="#3-2-有序列表" class="headerlink" title="3.2 有序列表"></a>3.2 有序列表</h2><p>有序列表使用数字并加上 <strong>.</strong> 号来表示，如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1. 第一项</span><br><span class="line">2. 第二项</span><br><span class="line">3. 第三项</span><br></pre></td></tr></table></figure>

<ol>
<li>第一项</li>
<li>第二项</li>
<li>第三项</li>
</ol>
<h2 id="3-3-列表嵌套"><a href="#3-3-列表嵌套" class="headerlink" title="3.3 列表嵌套"></a>3.3 列表嵌套</h2><p>列表嵌套只需在子列表中的选项前面添加两个或四个空格即可：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1. 第一项：</span><br><span class="line">    - 第一项嵌套的第一个元素</span><br><span class="line">    - 第一项嵌套的第二个元素</span><br><span class="line">2. 第二项：</span><br><span class="line">    - 第二项嵌套的第一个元素</span><br><span class="line">    - 第二项嵌套的第二个元素</span><br></pre></td></tr></table></figure>

<ol>
<li>第一项：<ul>
<li>第一项嵌套的第一个元素</li>
<li>第一项嵌套的第二个元素</li>
</ul>
</li>
<li>第二项：<ul>
<li>第二项嵌套的第一个元素</li>
<li>第二项嵌套的第二个元素</li>
</ul>
</li>
</ol>
<h1 id="4-区块"><a href="#4-区块" class="headerlink" title="4 区块"></a>4 区块</h1><h2 id="4-1-区块引用"><a href="#4-1-区块引用" class="headerlink" title="4.1 区块引用"></a>4.1 区块引用</h2><p>Markdown 区块引用是在段落开头使用 <strong>&gt;</strong> 符号 ，然后后面紧跟一个<strong>空格</strong>符号：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&gt; 区块引用</span><br><span class="line">&gt; 我是谁</span><br><span class="line">&gt; 同志们！革命尚未成功还需努力</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<blockquote>
<p>区块引用</p>
<p>我是谁</p>
<p>同志们！革命尚未成功还需努力</p>
</blockquote>
<p>另外区块是可以嵌套的，一个 <strong>&gt;</strong> 符号是最外层，两个 <strong>&gt;</strong> 符号是第一层嵌套，以此类推：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&gt; 最外层</span><br><span class="line">&gt; &gt; 第一层嵌套</span><br><span class="line">&gt; &gt; &gt; 第二层嵌套</span><br></pre></td></tr></table></figure>

<blockquote>
<p>11</p>
<blockquote>
<p>22</p>
<p>33</p>
</blockquote>
</blockquote>
<h2 id="4-2-区块中使用列表"><a href="#4-2-区块中使用列表" class="headerlink" title="4.2 区块中使用列表"></a>4.2 区块中使用列表</h2><p>区块中使用列表实例如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&gt; 区块中使用列表</span><br><span class="line">&gt; 1. 第一项</span><br><span class="line">&gt; 2. 第二项</span><br><span class="line">&gt; + 第一项</span><br><span class="line">&gt; + 第二项</span><br><span class="line">&gt; + 第三项</span><br></pre></td></tr></table></figure>

<blockquote>
<p>区块中使用列表</p>
<ol>
<li>第一项</li>
<li>第二项</li>
</ol>
<ul>
<li>第一项</li>
<li>第二项</li>
<li>第三项</li>
</ul>
</blockquote>
<h2 id="4-3-列表中使用区块"><a href="#4-3-列表中使用区块" class="headerlink" title="4.3 列表中使用区块"></a>4.3 列表中使用区块</h2><p>如果要在列表项目内放进区块，那么就需要在 <strong>&gt;</strong> 前添加四个空格的缩进。</p>
<p>列表中使用区块实例如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">* 第一项</span><br><span class="line">    &gt; 111</span><br><span class="line">    &gt; 2222</span><br><span class="line">* 第二项</span><br></pre></td></tr></table></figure>

<ul>
<li><p>第一项</p>
<blockquote>
<p>1</p>
<p>2</p>
<p>3</p>
<blockquote>
<p>3.1</p>
</blockquote>
</blockquote>
</li>
</ul>
<h1 id="5-代码块"><a href="#5-代码块" class="headerlink" title="5 代码块"></a>5 代码块</h1><h2 id="5-1-函数或片段"><a href="#5-1-函数或片段" class="headerlink" title="5.1 函数或片段"></a>5.1 函数或片段</h2><p>如果是段落上的一个函数或片段的代码可以用反引号把它包起来（**&#96;**），例如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">`printf()` 函数</span><br></pre></td></tr></table></figure>

<p><code>println()</code>函数</p>
<h2 id="5-2-代码区块"><a href="#5-2-代码区块" class="headerlink" title="5.2 代码区块"></a>5.2 代码区块</h2><p>代码区块使用 <strong>4 个空格</strong>或者一个<strong>制表符（Tab 键）</strong>。</p>
<p>实例如下：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">``</span><span class="string">`$(document).ready(function () &#123;</span></span><br><span class="line"><span class="string">    alert(&#x27;RUNOOB&#x27;);</span></span><br><span class="line"><span class="string">&#125;);`</span><span class="string">``</span></span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$(document).ready(function () &#123;</span><br><span class="line">    alert(&#x27;RUNOOB&#x27;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>



<h1 id="6-链接"><a href="#6-链接" class="headerlink" title="6 链接"></a>6 链接</h1><h2 id="6-1-普通用法"><a href="#6-1-普通用法" class="headerlink" title="6.1 普通用法"></a>6.1 普通用法</h2><p>链接使用方法如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">[链接名称](链接地址)</span><br><span class="line"></span><br><span class="line">或者</span><br><span class="line"></span><br><span class="line">&lt;链接地址&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>例如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">这是一个链接 [我的博客](https://www.cydhome.com)</span><br></pre></td></tr></table></figure>

<p>显示结果如下：</p>
<p><a href="w'w'w.cydhome.com">我的博客</a></p>
<h2 id="6-2-直接使用链接地址"><a href="#6-2-直接使用链接地址" class="headerlink" title="6.2 直接使用链接地址"></a>6.2 直接使用链接地址</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;https://www.cydhome.com&gt;</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://www.cydhome.com/">https://www.cydhome.com</a></p>
<h2 id="6-3高级链接"><a href="#6-3高级链接" class="headerlink" title="6.3高级链接"></a>6.3高级链接</h2><p>我们可以通过变量来设置一个链接，变量赋值在文档末尾进行：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">这个链接用 1 作为网址变量 [Google][1]</span><br><span class="line">这个链接用 cydhome 作为网址变量 [cydhome][myBlog]</span><br><span class="line">然后在文档的结尾为变量赋值（网址）</span><br><span class="line"></span><br><span class="line">  [1]: http://www.google.com/</span><br><span class="line">  [cydhome]: http://www.cydhome.com/</span><br></pre></td></tr></table></figure>

<p>这个链接用 1 作为网址变量 <a href="www.google.com">Google</a></p>
<p>这个链接用 myblog 作为网址变量 <a href="www.cydhome.com">cydhome</a></p>
<h1 id="7-图片"><a href="#7-图片" class="headerlink" title="7 图片"></a>7 图片</h1><h2 id="7-1常规用法"><a href="#7-1常规用法" class="headerlink" title="7.1常规用法"></a>7.1常规用法</h2><p>Markdown 图片语法格式如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">![alt 属性文本](图片地址)</span><br><span class="line"></span><br><span class="line">![alt 属性文本](图片地址 &quot;可选标题&quot;)</span><br></pre></td></tr></table></figure>

<ul>
<li>开头一个感叹号 !</li>
<li>接着一个方括号，里面放上图片的替代文字</li>
<li>接着一个普通括号，里面放上图片的网址，最后还可以用引号包住并加上选择性的 ‘title’ 属性的文字。</li>
</ul>
<p>使用实例：</p>
<p><img src="https://gitee.com/cydmacro/myblog/blob/master/img/%E6%9E%B6%E6%9E%841.drawio.png" alt="示例图片1"></p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20211122085641960.png" alt="示例图片2" title="图片标题"></p>
<h2 id="7-2-网址方式处理"><a href="#7-2-网址方式处理" class="headerlink" title="7.2 网址方式处理"></a>7.2 网址方式处理</h2><p>当然，你也可以像网址那样对图片网址使用变量:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">这个链接用 1 作为网址变量 [arch][arch1].</span><br><span class="line">然后在文档的结尾为变量赋值（网址）</span><br><span class="line"></span><br><span class="line">[1]: https://www.cydhome.com</span><br></pre></td></tr></table></figure>

<p>这个链接用 1 作为网址变量 <a target="_blank" rel="noopener" href="https://gitee.com/cydmacro/myblog/blob/master/img/%E6%9E%B6%E6%9E%841.drawio.png">arch</a></p>
<h2 id="7-3-指定图片高宽"><a href="#7-3-指定图片高宽" class="headerlink" title="7.3 指定图片高宽"></a>7.3 指定图片高宽</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;img decoding=&quot;async&quot; src=&quot;https://gitee.com/cydmacro/myblog/blob/master/img/%E6%9E%B6%E6%9E%841.drawio.png&quot; width=&quot;50%&quot;&gt;</span><br></pre></td></tr></table></figure>

<p>显示结果如下：</p>
<img decoding="async" src="https://gitee.com/cydmacro/myblog/blob/master/img/架构1.drawio.png" width="50%">



<h1 id="8-表格"><a href="#8-表格" class="headerlink" title="8 表格"></a>8 表格</h1><h2 id="8-1-设置表头和单元格"><a href="#8-1-设置表头和单元格" class="headerlink" title="8.1  设置表头和单元格"></a>8.1  设置表头和单元格</h2><p>Markdown 制作表格使用 <strong>|</strong> 来分隔不同的单元格，使用 <strong>-</strong> 来分隔表头和其他行。</p>
<p>语法格式如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">|  表头   | 表头  |</span><br><span class="line">|  ----  | ----  |</span><br><span class="line">| 单元格  | 单元格 |</span><br><span class="line">| 单元格  | 单元格 |</span><br></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th>表头</th>
<th>表头</th>
</tr>
</thead>
<tbody><tr>
<td>单元格</td>
<td>单元格</td>
</tr>
<tr>
<td>单元格</td>
<td>单元格</td>
</tr>
</tbody></table>
<h2 id="8-2-对齐方式"><a href="#8-2-对齐方式" class="headerlink" title="8.2 对齐方式"></a>8.2 对齐方式</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">我们可以设置表格的对齐方式：</span><br><span class="line"></span><br><span class="line">-: 设置内容和标题栏居右对齐。</span><br><span class="line">:- 设置内容和标题栏居左对齐。</span><br><span class="line">:-: 设置内容和标题栏居中对齐。</span><br></pre></td></tr></table></figure>

<p>实例如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">| 左对齐 | 右对齐 | 居中对齐 |</span><br><span class="line">| :-----| ----: | :----: |</span><br><span class="line">| 单元格 | 单元格 | 单元格 |</span><br><span class="line">| 单元格 | 单元格 | 单元格 |</span><br></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th align="left">左对齐</th>
<th align="right">右对齐</th>
<th align="center">居中对齐</th>
</tr>
</thead>
<tbody><tr>
<td align="left">单元格</td>
<td align="right">单元格</td>
<td align="center">单元格</td>
</tr>
<tr>
<td align="left">单元格</td>
<td align="right">单元格</td>
<td align="center">单元格</td>
</tr>
</tbody></table>
<h1 id="9-高级技巧"><a href="#9-高级技巧" class="headerlink" title="9 高级技巧"></a>9 高级技巧</h1><h2 id="9-1-支持的-HTML-元素"><a href="#9-1-支持的-HTML-元素" class="headerlink" title="9.1 支持的 HTML 元素"></a>9.1 支持的 HTML 元素</h2><p>不在 Markdown 涵盖范围之内的标签，都可以直接在文档里面用 HTML 撰写。</p>
<p>目前支持的 HTML 元素有：<code>&lt;kbd&gt; &lt;b&gt; &lt;i&gt; &lt;em&gt; &lt;sup&gt; &lt;sub&gt; &lt;br&gt;</code>等 ，如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">使用 &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;Del&lt;/kbd&gt; 重启电脑</span><br></pre></td></tr></table></figure>

<p>使用 <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Del</kbd> 重启电脑</p>
<h2 id="9-2-转义"><a href="#9-2-转义" class="headerlink" title="9.2 转义"></a>9.2 转义</h2><p>Markdown 使用了很多特殊符号来表示特定的意义，如果需要显示特定的符号则需要使用转义字符，Markdown 使用反斜杠转义特殊字符：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">**文本加粗** </span><br><span class="line">\*\* 正常显示星号 \*\*</span><br></pre></td></tr></table></figure>

<p>输出结果为：</p>
<p><strong>文本加粗</strong><br>** 正常显示星号 **</p>
<p>Markdown 支持以下这些符号前面加上反斜杠来帮助插入普通的符号：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">\   反斜线</span><br><span class="line">`   反引号</span><br><span class="line">*   星号</span><br><span class="line">_   下划线</span><br><span class="line">&#123;&#125;  花括号</span><br><span class="line">[]  方括号</span><br><span class="line">()  小括号</span><br><span class="line">#   井字号</span><br><span class="line">+   加号</span><br><span class="line">-   减号</span><br><span class="line">.   英文句点</span><br><span class="line">!   感叹号</span><br></pre></td></tr></table></figure>



<h2 id="9-3-公式"><a href="#9-3-公式" class="headerlink" title="9.3 公式"></a>9.3 公式</h2><p><strong>Markdown Preview Enhanced</strong> 使用 <a target="_blank" rel="noopener" href="https://github.com/Khan/KaTeX">KaTeX</a> 或者 <a target="_blank" rel="noopener" href="https://github.com/mathjax/MathJax">MathJax</a> 来渲染数学表达式。</p>
<p>KaTeX 拥有比 MathJax 更快的性能，但是它却少了很多 MathJax 拥有的特性。你可以查看 KaTeX supported functions&#x2F;symbols 来了解 KaTeX 支持那些符号和函数。</p>
<p>默认下的分隔符：</p>
<ul>
<li><code>$...$</code> 或者 <code>\(...\)</code> 中的数学表达式将会在行内显示。</li>
<li><code>$$...$$</code> 或者 <code>\[...\]</code> 或者 &#96;&#96;&#96;&#96;math&#96; 中的数学表达式将会在块内显示。</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">$$</span><br><span class="line">\begin&#123;Bmatrix&#125;</span><br><span class="line">   a &amp; b \\</span><br><span class="line">   c &amp; d</span><br><span class="line">\end&#123;Bmatrix&#125;</span><br><span class="line">$$</span><br><span class="line">$$</span><br><span class="line">\begin&#123;CD&#125;</span><br><span class="line">   A @&gt;a&gt;&gt; B \\</span><br><span class="line">@VbVV @AAcA \\</span><br><span class="line">   C @= D</span><br><span class="line">\end&#123;CD&#125;</span><br><span class="line">$$</span><br></pre></td></tr></table></figure>

<p>输出结果为：</p>
<p>$$<br>\begin{Bmatrix}<br>   a &amp; b \<br>   c &amp; d<br>\end{Bmatrix}<br>$$</p>
<p>$$<br>\begin{CD}<br>   A @&gt;a&gt;&gt; B \<br>@VbVV @AAcA \<br>   C @&#x3D; D<br>\end{CD}<br>$$</p>
<hr>
<h1 id="快捷键"><a href="#快捷键" class="headerlink" title="快捷键"></a>快捷键</h1><p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/580285461">https://zhuanlan.zhihu.com/p/580285461</a></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">插入表格：option + command + T</span><br><span class="line">无序号：- 或 *</span><br><span class="line">有序号： 阿拉伯数字后加上 . 后直接 ”空格“</span><br><span class="line">退出 序号 状态：”按两次回车键“，或按 command + [</span><br><span class="line">插入超链接：command + K</span><br><span class="line">文本加粗：command + B</span><br><span class="line">文本斜体：command + I</span><br><span class="line">文本下划线：command + U</span><br><span class="line">删除线：control + shift + `（tab键上面的那个键）</span><br><span class="line">文本加粗、文本斜体、文本下划线、删除线，可以随意组合叠加使用</span><br><span class="line">标题：command + 1 ；command + 2 ……；command + 7</span><br><span class="line">段落（正文）：command + 0</span><br><span class="line">水平分割线： 3个或3个以上的 -</span><br><span class="line">代码模块：option + command + C</span><br><span class="line">公式模块：option + command + B</span><br><span class="line">单个代码：control + ` （tab键上面的那个键）</span><br><span class="line">插入图片：control + command + I</span><br><span class="line">注释：control + -</span><br></pre></td></tr></table></figure>





 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-docker各种"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/09/28/docker%E5%90%84%E7%A7%8D/"
    >docker各种</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/09/28/docker%E5%90%84%E7%A7%8D/" class="article-date">
  <time datetime="2023-09-28T07:27:55.000Z" itemprop="datePublished">2023-09-28</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>修改镜像地址</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&quot;registry-mirrors&quot;: [</span><br><span class="line">    &quot;https://registry.docker-cn.com&quot;,</span><br><span class="line">    &quot;https://docker.mirrors.ustc.edu.cn&quot;,</span><br><span class="line">    &quot;https: //hub-mirror.c.163.com&quot;,</span><br><span class="line">    &quot;https://cr.console.aliyun.com&quot;,</span><br><span class="line">    &quot;https://mirror.ccs.tencentyun.com&quot;</span><br><span class="line">  ]</span><br></pre></td></tr></table></figure>

<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230928152958336.png" alt="image-20230928152958336"></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-架构笔记"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
     
    <div class="article-meta">
      <a href="/2023/09/20/%E6%9E%B6%E6%9E%84%E7%AC%94%E8%AE%B0/" class="article-date">
  <time datetime="2023-09-20T04:32:25.512Z" itemprop="datePublished">2023-09-20</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
   
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-架构师成长之路-1"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/09/01/%E6%9E%B6%E6%9E%84%E5%B8%88%E6%88%90%E9%95%BF%E4%B9%8B%E8%B7%AF-1/"
    >架构师成长之路-1</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/09/01/%E6%9E%B6%E6%9E%84%E5%B8%88%E6%88%90%E9%95%BF%E4%B9%8B%E8%B7%AF-1/" class="article-date">
  <time datetime="2023-09-01T01:59:04.000Z" itemprop="datePublished">2023-09-01</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
   
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E4%BB%8A%E5%A4%A9%E6%98%AF%E4%B8%AA%E5%A5%BD%E6%97%A5%E5%AD%90/" rel="tag">今天是个好日子</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-数据结构基础"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/18/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%9F%BA%E7%A1%80/"
    >数据结构基础</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/18/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%9F%BA%E7%A1%80/" class="article-date">
  <time datetime="2023-08-18T06:19:10.000Z" itemprop="datePublished">2023-08-18</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>链表</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-clickHouse常用命令"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/16/clickHouse%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/"
    >clickHouse常用命令</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/16/clickHouse%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="article-date">
  <time datetime="2023-08-16T02:05:49.000Z" itemprop="datePublished">2023-08-16</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="常用存储间类型对照，包含mysql-clickhouse-oracle-hive-flink-SQL"><a href="#常用存储间类型对照，包含mysql-clickhouse-oracle-hive-flink-SQL" class="headerlink" title="常用存储间类型对照，包含mysql,clickhouse,oracle,hive,flink SQL"></a>常用存储间类型对照，包含mysql,clickhouse,oracle,hive,flink SQL</h1><p>转载：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44056920/article/details/119826740">https://blog.csdn.net/weixin_44056920/article/details/119826740</a></p>
<p>不同存储间数据传输的时候，类型匹配是个很让人头疼的事情，笔者总结了常用几种存储的类型对照，以供参考。有不准确的地方，欢迎批评指正~</p>
<table>
<thead>
<tr>
<th>Java类型</th>
<th>MySQL类型</th>
<th>ClickHouse类型</th>
<th>Oracle类型</th>
<th>Hive类型</th>
<th>Flink SQL类型</th>
</tr>
</thead>
<tbody><tr>
<td>boolean</td>
<td>boolean tinyint(1)</td>
<td>UInt8</td>
<td>NUMBER(1)</td>
<td>boolean</td>
<td>BOOLEAN</td>
</tr>
<tr>
<td>byte</td>
<td>tinyint</td>
<td>Int8</td>
<td>NUMBER(3,0)</td>
<td>tinyint</td>
<td>TINYINT</td>
</tr>
<tr>
<td>short</td>
<td>smallint tinyint unsigned</td>
<td>Int16 uint8</td>
<td>NUMBER(5,0)</td>
<td>smallint</td>
<td>SMALLINT</td>
</tr>
<tr>
<td>int</td>
<td>int mediumint smallint unsigned mediumint unsigned</td>
<td>Int32 uint16</td>
<td>NUMBER(10,0)</td>
<td>int</td>
<td>INT</td>
</tr>
<tr>
<td>long</td>
<td>bigint int unsigned</td>
<td>Int64 UInt32</td>
<td>NUMBER(20,0)</td>
<td>bigint</td>
<td>BIGINT</td>
</tr>
<tr>
<td>bigint<br/>（<em>java.math.BigInteger</em>）</td>
<td>bigint unsigned<br/>（<code>mysql官网不建议使用</code>）</td>
<td>Int128<br/>Int256<br/>uInt64<br/>uInt128<br/>uInt256</td>
<td></td>
<td></td>
<td><code>不支持</code>（java.sql.Types不支持，因此Flink SQL也不支持，DataStream api中的TypeInformation是支持的）</td>
</tr>
<tr>
<td>float</td>
<td>float float unsigned（<code>官网不建议使用</code>）</td>
<td>Float32</td>
<td>BINARY_FLOAT</td>
<td>float</td>
<td>FLOAT</td>
</tr>
<tr>
<td>double</td>
<td>double double unsigned（<code>官网不建议使用</code>）</td>
<td>Float64</td>
<td>BINARY_DOUBLE</td>
<td>double</td>
<td>DOUBLE</td>
</tr>
<tr>
<td>String</td>
<td>varchar char text tinytext mediumtext longtext</td>
<td>String uuid fixedString</td>
<td>VARCHAR2 NVARCHAR2 CHAR NCHAR LONG</td>
<td>string</td>
<td>STRING VARCHAR</td>
</tr>
<tr>
<td>decimal</td>
<td>decimal numeric precision</td>
<td>Decimal</td>
<td>NUMBER FLOAT</td>
<td></td>
<td>DECIMAL</td>
</tr>
<tr>
<td>date</td>
<td>date year</td>
<td>Date</td>
<td></td>
<td></td>
<td>DATE</td>
</tr>
<tr>
<td>time</td>
<td>time</td>
<td></td>
<td></td>
<td></td>
<td>TIME(0)</td>
</tr>
<tr>
<td>timestamp</td>
<td>timestamp datetime</td>
<td>datetime64</td>
<td>date（与mysql类型有歧义）</td>
<td>timestamp</td>
<td>TIMESTAMP</td>
</tr>
<tr>
<td>byte[]</td>
<td>blob binary varbinary tinyblob mediumblob longblob</td>
<td></td>
<td>RAW</td>
<td></td>
<td>BYTES</td>
</tr>
</tbody></table>
<pre><code>注：
对照表中每格第一个为优先级最高的，一对多时优先选择
对照不出来的，一律对照成String，此时需要进行类型强转（表示该存储没有可以直接对照的数据类型）
mysql bigint unsigned官网不建议适用，并且明确说明应使用String存储https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html`
</code></pre>
<h1 id="进入客户端"><a href="#进入客户端" class="headerlink" title="进入客户端"></a>进入客户端</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">clickhouse-client -h 127.0.0.1 -m -u default --password 123456</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">-- 将数据导入到ReplacingMergeTree表</span><br><span class="line">insert into replace_log select * from raw_log;</span><br><span class="line"></span><br><span class="line">-- 触发合并，进行去重</span><br><span class="line">OPTIMIZE TABLE replace_log final;</span><br><span class="line"></span><br><span class="line">-- 删除原表的数据</span><br><span class="line">alter table raw_log delete where 1=1;</span><br><span class="line"></span><br><span class="line">-- 将ReplacingMergeTree表合并后的数据写回原表</span><br><span class="line">insert into raw_log select * from replace_log;</span><br></pre></td></tr></table></figure>

<h1 id="备份脚本"><a href="#备份脚本" class="headerlink" title="备份脚本"></a>备份脚本</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">#!/bin/bash</span><br><span class="line"></span><br><span class="line">OUTDIR=/usr/local/etl/backup/</span><br><span class="line"></span><br><span class="line">clickhouse-client --password=123456   -q &quot;SHOW DATABASES&quot; &gt; /usr/local/etl/backup/db.txt</span><br><span class="line">while read -r db</span><br><span class="line">do</span><br><span class="line">        clickhouse-client --password=123456 -q &quot;SHOW TABLES FROM $db&quot; &gt; /usr/local/etl/backup/table.txt</span><br><span class="line">        #echo &quot;--------------------------------$&#123;db&#125;&quot;</span><br><span class="line">        while read -r table</span><br><span class="line">        do</span><br><span class="line">                if [ &quot;$db&quot; == &quot;system&quot; ]; then</span><br><span class="line">                echo &quot;skip system db&quot;</span><br><span class="line">                continue 2;</span><br><span class="line">                fi</span><br><span class="line"></span><br><span class="line">                if [[ &quot;$table&quot; == &quot;.inner.&quot;* ]]; then</span><br><span class="line">                echo &quot;skip materialized view $table ($db)&quot;</span><br><span class="line">                continue;</span><br><span class="line">                fi</span><br><span class="line"></span><br><span class="line">                echo &quot;export table $table from database $db&quot;</span><br><span class="line"></span><br><span class="line">                # dump schema</span><br><span class="line">                clickhouse-client --password=123456 -q &quot;SHOW CREATE TABLE $&#123;db&#125;.$&#123;table&#125; format CSV&quot; &gt;&gt; &quot;$&#123;OUTDIR&#125;/schema.sql&quot;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">  done  &lt; `ls /usr/local/etl/backup/table.txt`</span><br><span class="line">done  &lt; `ls /usr/local/etl/backup/db.txt`</span><br></pre></td></tr></table></figure>

<h1 id="clickhouse中如何查询分区表分区及表容量查询"><a href="#clickhouse中如何查询分区表分区及表容量查询" class="headerlink" title="clickhouse中如何查询分区表分区及表容量查询"></a>clickhouse中如何查询分区表分区及表容量查询</h1><p>转载自<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_41018861/article/details/116149198">https://blog.csdn.net/qq_41018861/article/details/116149198</a></p>
<p>clickhouse中如何查询分区表分区及表容量–这个问题相信大家在使用clickhouse分区表时都会经常遇到，其实clickhouse表的元数据信息都存储在system.parts表中，可以通过该表对clickhouse上所有表进行查询表容量大小、行数、压缩率及分区信息等进行查询了解。</p>
<h2 id="1-system-parts表schema解析"><a href="#1-system-parts表schema解析" class="headerlink" title="1. system.parts表schema解析"></a>1. system.parts表<a target="_blank" rel="noopener" href="https://so.csdn.net/so/search?q=schema&spm=1001.2101.3001.7020">schema</a>解析</h2><p>system.parts表schema说明如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">`partition`（String）-- 分区名称。</span><br><span class="line">`name`（String）-- 数据部分的名称。</span><br><span class="line">`part_type`（String）-- 数据部分的存储格式。</span><br><span class="line">`active`（UInt8）-- 指示数据部分是否处于活动状态的标志。如果数据部分处于活动状态，则会在表中使用它。否则，将其删除。合并后，不活动的数据部分仍然保留。</span><br><span class="line">`marks`（UInt64）-- 标记数。要获得数据部分中的大约行数，请乘以marks索引粒度（通常为8192）（此提示不适用于自适应粒度）。</span><br><span class="line">`rows`（UInt64）-- 行数。</span><br><span class="line">`bytes_on_disk`（UInt64）-- 所有数据片段的总大小（以字节为单位）。</span><br><span class="line">`data_compressed_bytes`（UInt64）-- 数据片段中压缩数据的总大小。不包括所有辅助文件（例如，带标记的文件）。</span><br><span class="line">`data_uncompressed_bytes`（UInt64）-- 数据片段中未压缩数据的总大小。不包括所有辅助文件（例如，带标记的文件）。</span><br><span class="line">`marks_bytes`（UInt64）-- 带标记的文件的大小。</span><br><span class="line">`modification_time`（DateTime） --包含数据片段的目录被修改的时间。这通常对应于数据零件创建的时间。</span><br><span class="line">`remove_time`（DateTime）-- 数据片段变为非活动状态的时间。</span><br><span class="line">`refcount`（UInt32）-- 使用数据片段的位置数。大于2的值表示在查询或合并中使用了数据部分。</span><br><span class="line">`min_date`（Date）-- 数据片段中日期键的最小值。</span><br><span class="line">`max_date`（Date） -- 数据片段中日期键的最大值。</span><br><span class="line">`min_time`（DateTime）-- 数据片段中日期和时间键的最小值。</span><br><span class="line">`max_time`（DateTime）-- 数据片段中日期和时间键的最大值。</span><br><span class="line">`partition_id`（String）-- 分区的ID。</span><br><span class="line">`min_block_number`（UInt64）-- 合并后组成当前部分的数据片段的最小数量。</span><br><span class="line">`max_block_number`（UInt64）-- 合并后组成当前部分的最大数据片段数。</span><br><span class="line">`level`（UInt32）-- 合并树的深度。零表示当前零件是通过插入而不是通过合并其他零件来创建的。</span><br><span class="line">`data_version`（UInt64）-- 用于确定应将哪些突变应用于数据部分（版本高于的突变data_version）的编号。</span><br><span class="line">`primary_key_bytes_in_memory`（UInt64）-- 主键值使用的内存量（以字节为单位）。</span><br><span class="line">`primary_key_bytes_in_memory_allocated`（UInt64）-- 为主键值保留的内存量（以字节为单位）。</span><br><span class="line">`is_frozen`（UInt8）-- 显示分区数据备份存在的标志。1，备份存在。0，备份不存在。有关更多详细信息，请参见“冻结分区”。</span><br><span class="line">`database`（String）-- 数据库的名称。</span><br><span class="line">`table`（String）-- 表的名称。</span><br><span class="line">`engine`（String）-- 不带参数的表引擎的名称。</span><br><span class="line">`path`（字符串）-- 包含数据零件文件的文件夹的绝对路径。</span><br><span class="line">`disk`（字符串）-- 存储数据部分的磁盘的名称。</span><br><span class="line">`hash_of_all_files`（字符串）-- 压缩文件的sipHash128。</span><br><span class="line">`hash_of_uncompressed_files`（String）-- 未压缩文件（带有标记的文件，索引文件等）的sipHash128。</span><br><span class="line">`uncompressed_hash_of_compressed_files`（String）-- 压缩文件中的数据的sipHash128，就好像它们是未压缩的一样。</span><br><span class="line">`delete_ttl_info_min`（DateTime）-- TTL DELETE规则的日期和时间键的最小值。</span><br><span class="line">`delete_ttl_info_max`（DateTime）-- TTL DELETE规则的日期和时间键的最大值。</span><br><span class="line">`move_ttl_info.expression`（Array（String））-- 表达式数组。每个表达式定义一个TTL MOVE规则。</span><br><span class="line">`move_ttl_info.min`（Array（DateTime））-- 日期和时间值的数组。每个元素都描述了TTL MOVE规则的最小键值。</span><br><span class="line">`move_ttl_info.max`（Array（DateTime））-- 日期和时间值的数组。每个元素都描述了TTL MOVE规则的最大键值。</span><br><span class="line">`bytes`（UInt64）-- bytes_on_disk的别名。</span><br><span class="line">`marks_size`（UInt64）-- marks_bytes的别名。</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="2-查看数据库总体容量、行数、压缩率"><a href="#2-查看数据库总体容量、行数、压缩率" class="headerlink" title="2.查看数据库总体容量、行数、压缩率"></a>2.查看数据库总体容量、行数、压缩率</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">localhost :) SELECT</span><br><span class="line">:-]     sum(rows) AS `总行数`,</span><br><span class="line">:-]     formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">:-]     formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">:-] FROM system.parts;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    sum(rows) AS `总行数`,</span><br><span class="line">    formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">FROM system.parts</span><br><span class="line"></span><br><span class="line">Query id: 38b59b29-d394-48a3-9424-c7354270b8ea</span><br><span class="line"></span><br><span class="line">┌─────总行数─┬─原始大小─┬─压缩大小───┬─压缩率─┐</span><br><span class="line">│ 8751892418 │ 3.06 TiB │ 345.38 GiB │     11 │</span><br><span class="line">└────────────┴──────────┴────────────┴────────┘</span><br><span class="line"></span><br><span class="line">1 rows in set. Elapsed: 1.679 sec. Processed 18.14 thousand rows, 11.92 MB (10.80 thousand rows/s., 7.10 MB/s.)</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="3-查看数据表容量、行数、压缩率"><a href="#3-查看数据表容量、行数、压缩率" class="headerlink" title="3.查看数据表容量、行数、压缩率"></a>3.查看数据表容量、行数、压缩率</h2><p>在此查询一张测试标签表的信息</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">--在此查询一张临时表的信息</span><br><span class="line">localhost :) SELECT</span><br><span class="line">:-]     table AS `表名`,</span><br><span class="line">:-]     sum(rows) AS `总行数`,</span><br><span class="line">:-]     formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">:-]     formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">:-] FROM system.parts</span><br><span class="line">:-] WHERE table IN (&#x27;label&#x27;)</span><br><span class="line">:-] GROUP BY table;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    table AS `表名`,</span><br><span class="line">    sum(rows) AS `总行数`,</span><br><span class="line">    formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">FROM system.parts</span><br><span class="line">WHERE table IN (&#x27;label&#x27;)</span><br><span class="line">GROUP BY table</span><br><span class="line"></span><br><span class="line">Query id: da621ae1-5a1b-4394-8ccd-db60bf628bfd</span><br><span class="line"></span><br><span class="line">┌─表名──┬─总行数─┬─原始大小─┬─压缩大小─┬─压缩率─┐</span><br><span class="line">│ label │      3 │ 86.00 B  │ 151.00 B │    176 │</span><br><span class="line">└───────┴────────┴──────────┴──────────┴────────┘</span><br><span class="line"></span><br><span class="line">1 rows in set. Elapsed: 0.005 sec.</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="4-查看数据表分区信息"><a href="#4-查看数据表分区信息" class="headerlink" title="4.查看数据表分区信息"></a>4.查看数据表分区信息</h2><p>查看测试表在20年12月的分区信息</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">--查看测试表在20年12月的分区信息</span><br><span class="line">localhost :) SELECT</span><br><span class="line">:-]     partition AS `分区`,</span><br><span class="line">:-]     sum(rows) AS `总行数`,</span><br><span class="line">:-]     formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">:-]     formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">:-] FROM system.parts</span><br><span class="line">:-] WHERE (database IN (&#x27;fct_boss&#x27;)) AND (table IN (&#x27;fct_boss_register_event&#x27;)) AND (partition LIKE &#x27;2020-12-%&#x27;)</span><br><span class="line">:-] GROUP BY partition</span><br><span class="line">:-] ORDER BY partition ASC;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    partition AS `分区`,</span><br><span class="line">    sum(rows) AS `总行数`,</span><br><span class="line">    formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">FROM system.parts</span><br><span class="line">WHERE (database IN (&#x27;fct_boss&#x27;)) AND (table IN (&#x27;fct_boss_register_event&#x27;)) AND (partition LIKE &#x27;2020-12-%&#x27;)</span><br><span class="line">GROUP BY partition</span><br><span class="line">ORDER BY partition ASC</span><br><span class="line"></span><br><span class="line">Query id: 3c4c68e7-bdf1-41c7-a337-ddbdc3dfab1b</span><br><span class="line"></span><br><span class="line">┌─分区────────┬─总行数──┬─原始大小───┬─压缩大小─────┬──压缩率─┐</span><br><span class="line">│ 2020-12-01 │  14060 │ 2.62 MiB  │ 810.42 KiB  │     30 │</span><br><span class="line">│ 2020-12-02 │  13010 │ 2.44 MiB  │ 759.27 KiB  │     30 │</span><br><span class="line">│ 2020-12-03 │  13918 │ 2.62 MiB  │ 817.41 KiB  │     30 │</span><br><span class="line">│ 2020-12-04 │  22038 │ 4.12 MiB  │ 1.26 MiB    │     31 │</span><br><span class="line">│ 2020-12-05 │  30104 │ 5.57 MiB  │ 1.72 MiB    │     31 │</span><br><span class="line">│ 2020-12-06 │  30606 │ 5.72 MiB  │ 1.74 MiB    │     30 │</span><br><span class="line">│ 2020-12-07 │  20413 │ 3.83 MiB  │ 1.16 MiB    │     30 │</span><br><span class="line">│ 2020-12-08 │  12305 │ 2.31 MiB  │ 711.07 KiB  │     30 │</span><br><span class="line">|  ......    |        |           |             |        |</span><br><span class="line">└────────────┴────────┴───────────┴─────────────┴────────┘</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="5-查看数据表字段的信息"><a href="#5-查看数据表字段的信息" class="headerlink" title="5.查看数据表字段的信息"></a>5.查看数据表字段的信息</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">localhost :) SELECT</span><br><span class="line">:-]     column AS `字段名`,</span><br><span class="line">:-]     any(type) AS `类型`,</span><br><span class="line">:-]     formatReadableSize(sum(column_data_uncompressed_bytes)) AS `原始大小`</span><br><span class="line">:-]     formatReadableSize(sum(column_data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     sum(rows) AS `行数`</span><br><span class="line">:-] FROM system.parts_columns</span><br><span class="line">:-] WHERE (database = &#x27;test&#x27;) AND (table = &#x27;label&#x27;)</span><br><span class="line">:-] GROUP BY column</span><br><span class="line">:-] ORDER BY column ASC ;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    column AS `字段名`,</span><br><span class="line">    any(type) AS `类型`,</span><br><span class="line">    formatReadableSize(sum(column_data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(column_data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    sum(rows) AS `行数`</span><br><span class="line">FROM system.parts_columns</span><br><span class="line">WHERE (database = &#x27;test&#x27;) AND (table = &#x27;label&#x27;)</span><br><span class="line">GROUP BY column</span><br><span class="line">ORDER BY column ASC</span><br><span class="line"></span><br><span class="line">Query id: 6cbed55b-94e6-46c5-b965-93f71875bb39</span><br><span class="line"></span><br><span class="line">┌─字段名─────┬─类型──────────┬─原始大小─┬─压缩大小─┬─行数─┐</span><br><span class="line">│ childs     │ Array(String) │ 0.00 B   │ 0.00 B   │    3 │</span><br><span class="line">│ label_name │ String        │ 0.00 B   │ 0.00 B   │    3 │</span><br><span class="line">│ user_id    │ String        │ 0.00 B   │ 0.00 B   │    3 │</span><br><span class="line">└────────────┴───────────────┴──────────┴──────────┴──────┘</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="6-system-parts-columns表-schema解析"><a href="#6-system-parts-columns表-schema解析" class="headerlink" title="6. system.parts_columns表 schema解析"></a>6. system.parts_columns表 schema解析</h2><p>system.parts_columns表 schema说明如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">`partition`（String）-- 分区名称。</span><br><span class="line">`name`（String）-- 数据片段的名称。</span><br><span class="line">`part_type`（String）-- 数据片段的存储格式。</span><br><span class="line">`active`（UInt8）-- 指示数据部分是否处于活动状态的标志。如果数据部分处于活动状态，则会在表中使用它。否则，将其删除。合并后，不活动的数据部分仍然保留。</span><br><span class="line">`marks`（UInt64）-- 标记数。要获得数据部分中的大约行数，请乘以marks索引粒度（通常为8192）（此提示不适用于自适应粒度）。</span><br><span class="line">`rows`（UInt64）-- 行数。</span><br><span class="line">`bytes_on_disk`（UInt64）-- 所有数据部分文件的总大小（以字节为单位）。</span><br><span class="line">`data_compressed_bytes`（UInt64）-- 数据部分中压缩数据的总大小。不包括所有辅助文件（例如，带标记的文件）。</span><br><span class="line">`data_uncompressed_bytes` （UInt64） --数据部分中未压缩数据的总大小。不包括所有辅助文件 （例如，带标记的文件）。</span><br><span class="line">`marks_bytes` （UInt64） --带有标记的文件的大小。</span><br><span class="line">`modification_time` （DateTime） --包含数据部分的目录被修改的时间。这通常对应于数据零件创建的时间。</span><br><span class="line">`remove_time` （DateTime） --数据部分变为非活动状态的时间。</span><br><span class="line">`refcount` （UInt32） --使用数据部分的位置数。大于2的值表示在查询或合并中使用了数据部分。</span><br><span class="line">`min_date` （Date） --数据部分中日期键的最小值。</span><br><span class="line">`max_date` （Date） --数据部分中日期密钥的最大值。</span><br><span class="line">`partition_id` （String） --分区的ID。</span><br><span class="line">`min_block_number` （UInt64） --合并后组成当前部分的数据部分的最小数量。</span><br><span class="line">`max_block_number` （UInt64） --合并后组成当前部分的最大数据部分数。</span><br><span class="line">`level` （UInt32） --合并树的深度。零表示当前零件是通过插入而不是通过合并其他零件来创建的。</span><br><span class="line">`data_version` （UInt64） --用于确定应将哪些突变应用于数据部分 （版本高于的突变data_version）的编号。</span><br><span class="line">`primary_key_bytes_in_memory` （UInt64） --主键值使用的内存量 （以字节为单位）。</span><br><span class="line">`primary_key_bytes_in_memory_allocated` （UInt64） --为主键值保留的内存量 （以字节为单位）。</span><br><span class="line">`database` （String） --数据库名称。</span><br><span class="line">`table` （String） --表的名称。</span><br><span class="line">`engine` （String） --不带参数的表引擎的名称。</span><br><span class="line">`disk_name` （String） --存储数据部分的磁盘的名称。</span><br><span class="line">`path` （String） --包含数据零件文件的文件夹的绝对路径。</span><br><span class="line">`column` （String） --列的名称。</span><br><span class="line">`type` （String） --列类型。</span><br><span class="line">`column_position` （UInt64） --以1开头的表中列的顺序位置。</span><br><span class="line">`default_kind` （字符串）  --表达类型 （DEFAULT，MATERIALIZED，ALIAS作为默认值），或者如果没有定义它为空字符串。</span><br><span class="line">`default_expression` （String） --默认值的表达式，如果未定义，则为空字符串。</span><br><span class="line">`column_bytes_on_disk` （UInt64） --列的总大小，以字节为单位。</span><br><span class="line">`column_data_compressed_bytes` （UInt64） --列中压缩数据的总大小，以字节为单位。</span><br><span class="line">`column_data_uncompressed_bytes` （UInt64） --列中解压缩数据的总大小，以字节为单位。</span><br><span class="line">`column_marks_bytes` （UInt64） --带标记的列的大小，以字节为单位。</span><br><span class="line">`bytes` （UInt64） --的别名bytes_on_disk。</span><br><span class="line">`marks_size` （UInt64） --的别名marks_bytes。</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="flink正常启动和checkPoint恢复启动"><a href="#flink正常启动和checkPoint恢复启动" class="headerlink" title="flink正常启动和checkPoint恢复启动"></a>flink正常启动和checkPoint恢复启动</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">#正常启动</span><br><span class="line">cd  /usr/local/etl/flink/flink/bin</span><br><span class="line">./flink run -c com.ziyi.cdc.intercity.ExecuteCdc -p 1 /usr/local/etl/ziyi_cdc/cdc-0.0.1-SNAPSHOT-jar-with-dependencies.jar</span><br><span class="line">参数含义：</span><br><span class="line">    -c 启动类路径（com.ziyi.cdc.intercity.ExecuteCdc）</span><br><span class="line">    -p 1   并行度等于1</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">--从checkPoint恢复启动</span><br><span class="line">cd  /usr/local/etl/flink/flink/bin</span><br><span class="line">./flink run -s file:///home/hdfs/cdc-point/ck/dc9b7e1fff60f393277b607c7df009af/chk-964120 -c  com.ziyi.cdc.intercity.ExecuteCdc  /usr/local/etl/ziyi_cdc/cdc-0.0.1-SNAPSHOT-jar-with-dependencies.jar</span><br><span class="line">参数含义：</span><br><span class="line">      1、 -s    指定checkPoint/savePoint的路径（file:///home/hdfs/cdc-point/ck/ef2d8d8939bd5b5189ab8ddc30e87475/chk-49）</span><br><span class="line">                文件恢复路径，固定不变file:///home/hdfs/cdc-point/ck/</span><br><span class="line">                最新的检查点文件夹，用时间最接近的，chk-49原则用最大编号的文件夹  ef2d8d8939bd5b5189ab8ddc30e87475/chk-49</span><br><span class="line">      2、-c     启动类路径（com.ziyi.cdc.intercity.ExecuteCdc）</span><br><span class="line">      3、jar路径（/usr/local/etl/ziyi_cdc/cdc-0.0.1-SNAPSHOT-jar-with-dependencies.jar）</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-linux常用命令"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/14/linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/"
    >linux常用命令</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/14/linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="article-date">
  <time datetime="2023-08-14T07:42:37.000Z" itemprop="datePublished">2023-08-14</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="Linux里利用grep和find查找文件内容"><a href="#Linux里利用grep和find查找文件内容" class="headerlink" title="Linux里利用grep和find查找文件内容"></a>Linux里利用grep和find查找文件内容</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">Linux里利用grep和find查找文件内容</span><br><span class="line">1、从文件内容查找匹配指定字符串的行：</span><br><span class="line">$ grep “被查找的字符串” 文件名</span><br><span class="line">例子：在当前目录里第一级文件夹中寻找包含指定字符串的.in文件</span><br><span class="line">grep “thermcontact” /.in</span><br><span class="line"></span><br><span class="line">2、从文件内容查找与正则表达式匹配的行：</span><br><span class="line">$ grep –e “正则表达式” 文件名</span><br><span class="line"></span><br><span class="line">3、查找时不区分大小写：</span><br><span class="line">$ grep –i “被查找的字符串” 文件名</span><br><span class="line"></span><br><span class="line">4、查找匹配的行数：</span><br><span class="line">$ grep -c “被查找的字符串” 文件名</span><br><span class="line"></span><br><span class="line">5、从文件内容查找不匹配指定字符串的行：</span><br><span class="line">$ grep –v “被查找的字符串” 文件名</span><br><span class="line"></span><br><span class="line">6、从根目录开始查找所有扩展名为.log的文本文件，并找出包含”ERROR”的行</span><br><span class="line">find / -type f -name “*.log” | xargs grep “ERROR”</span><br><span class="line">例子：从当前目录开始查找所有扩展名为.in的文本文件，并找出包含”thermcontact”的行</span><br><span class="line">find . -name “*.in” | xargs grep “thermcontact”</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="linux下进程号查看和pid查看端口号"><a href="#linux下进程号查看和pid查看端口号" class="headerlink" title="linux下进程号查看和pid查看端口号"></a>linux下进程号查看和pid查看端口号</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">1.  根据进程pid查端口：</span><br><span class="line"></span><br><span class="line">     lsof -i | grep pid</span><br><span class="line"></span><br><span class="line">2.  根据端口port查进程（某次面试还考过）：</span><br><span class="line"></span><br><span class="line">    lsof  -i:port     </span><br><span class="line"></span><br><span class="line">3. 根据进程pid查端口：</span><br><span class="line"></span><br><span class="line">   netstat -nap | grep pid</span><br><span class="line"></span><br><span class="line">4.  根据端口port查进程</span><br><span class="line"></span><br><span class="line">   netstat -nap | grep port</span><br><span class="line"></span><br><span class="line"> 从形式上看， netstat -nap 更好记忆， 但lsof的用法也要熟练。</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="Linux查看所有Java进程"><a href="#Linux查看所有Java进程" class="headerlink" title="Linux查看所有Java进程"></a>Linux查看所有Java进程</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">ps -ef | grep java | grep -v grep </span><br><span class="line"></span><br><span class="line">使用awk分割结果，获取PID</span><br><span class="line">ps -ef | grep java | grep -v grep | awk &#x27;&#123;print $2&#125;&#x27;</span><br><span class="line"></span><br><span class="line">ps -ef | grep java | grep -v grep | awk &#x27;&#123;print $2&#125;&#x27; | xargs kill -9</span><br><span class="line"></span><br></pre></td></tr></table></figure>





<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line">复制代码</span><br><span class="line"># 总核数 = 物理CPU个数 X 每颗物理CPU的核数 </span><br><span class="line"># 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数</span><br><span class="line"></span><br><span class="line"># 查看物理CPU个数</span><br><span class="line">cat /proc/cpuinfo| grep &quot;physical id&quot;| sort| uniq| wc -l</span><br><span class="line"></span><br><span class="line"># 查看每个物理CPU中core的个数(即核数)</span><br><span class="line">cat /proc/cpuinfo| grep &quot;cpu cores&quot;| uniq</span><br><span class="line"></span><br><span class="line"># 查看逻辑CPU的个数</span><br><span class="line">cat /proc/cpuinfo| grep &quot;processor&quot;| wc -l</span><br><span class="line">复制代码</span><br><span class="line"> 查看CPU信息（型号）</span><br><span class="line">cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line"></span><br><span class="line">查看内存信息</span><br><span class="line"># cat /proc/meminfo</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line"></span><br><span class="line">如何查看Linux 内核</span><br><span class="line">uname -a</span><br><span class="line">cat /proc/version</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line"></span><br><span class="line">查看机器型号（机器硬件型号）</span><br><span class="line"></span><br><span class="line">dmidecode | grep &quot;Product Name&quot;</span><br><span class="line">dmidecode</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">如何查看linux 系统版本</span><br><span class="line">cat /etc/redhat-release</span><br><span class="line">lsb_release -a</span><br><span class="line">cat  /etc/issue</span><br><span class="line"> </span><br><span class="line">如何查看linux系统和CPU型号，类型和大小</span><br><span class="line">cat /proc/cpuinfo</span><br><span class="line"></span><br><span class="line">如何查看linux 系统内存大小的信息，可以查看总内存，剩余内存，可使用内存等信息  </span><br><span class="line">cat /proc/meminfo</span><br></pre></td></tr></table></figure>



<h1 id="Linux-x2F-Mac下统计当前文件夹下的文件个数、目录个数"><a href="#Linux-x2F-Mac下统计当前文件夹下的文件个数、目录个数" class="headerlink" title="Linux&#x2F;Mac下统计当前文件夹下的文件个数、目录个数"></a>Linux&#x2F;Mac下统计当前文件夹下的文件个数、目录个数</h1><p>这篇文章主要介绍了Linux下统计当前文件夹下的文件个数、目录个数,本文使用ls命令配合管理、grep命令实现统计需求,需要的朋友可以参考下 不好意思，为了不让该帖子沉下去，造福需要改机的机友们，所以加上了回复才能查看的内容。</p>
<p>1.统计当前文件夹下文件的个数<br><code>ls -l |grep &quot;^-&quot;|wc -l</code></p>
<p>2、 统计当前文件夹下目录的个数<br><code>ls -l |grep &quot;^d&quot;|wc -l</code><br>3、 统计当前文件夹下文件的个数，包括子文件夹里的<br><code>ls -lR|grep &quot;^-&quot;|wc -l</code><br>4、统计文件夹下目录的个数，包括子文件夹里的<br><code>ls -lR|grep &quot;^d&quot;|wc -l</code></p>
<ol>
<li>说明</li>
</ol>
<blockquote>
<p>代码如下:</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls -l</span><br></pre></td></tr></table></figure>

<p>长列表输出当前文件夹下文件信息(注意这里的文件，不同于一般的文件，可能是目录、链接、设备文件等)</p>
<p>代码如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grep &quot;^-&quot;</span><br></pre></td></tr></table></figure>

<p>这里将长列表输出信息过滤一部分，只保留一般文件，如果只保留目录就是 ^d<br>代码如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wc -l</span><br></pre></td></tr></table></figure>

<p>统计输出信息的行数，因为已经过滤得只剩一般文件了，所以统计结果就是一般文件信息的行数，又由于一行信息对应一个文件，所以也就是文件的个数。</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-数据库表扩容导致数据不均匀问题解决⽅案-加权负载均衡"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/04/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8%E6%89%A9%E5%AE%B9%E5%AF%BC%E8%87%B4%E6%95%B0%E6%8D%AE%E4%B8%8D%E5%9D%87%E5%8C%80%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E2%BD%85%E6%A1%88-%E5%8A%A0%E6%9D%83%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/"
    >数据库表扩容导致数据不均匀问题解决⽅案-加权负载均衡</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/04/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8%E6%89%A9%E5%AE%B9%E5%AF%BC%E8%87%B4%E6%95%B0%E6%8D%AE%E4%B8%8D%E5%9D%87%E5%8C%80%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E2%BD%85%E6%A1%88-%E5%8A%A0%E6%9D%83%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/" class="article-date">
  <time datetime="2023-08-04T11:39:24.000Z" itemprop="datePublished">2023-08-04</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>下面我们来看下业务场景：</p>
<p>1、比如我们上线了一个项目，采用sharding分库分表，其中比较关键的一个服务前期给了2个库，因为项目比较火爆每个库接近千万数据量；</p>
<p>2、这个时候想到扩容，新加了4个库，然后数据量正常写入，但是很快老数据库的数据量就超过千万，而新数据库没有那么多数据，这个时候你想到问题了吗？</p>
<p>问题是：老的库和新的库写入数据不均衡，忙的忙，“闲的闲”。这个时候想到了nginx负载均衡算法不是有，轮询，权重等等。到这是不是知道答案了，是的，借鉴加权负载均衡算法可以解决这个问题。</p>
<p>直接看代码吧</p>
<p>改造前</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">  private static final List&lt;String&gt; dbPrefixList = new ArrayList&lt;&gt;();</span><br><span class="line">    //配置启用那些库的前缀，原来只有a,b</span><br><span class="line">    static &#123;</span><br><span class="line">        dbPrefixList.add(&quot;a&quot;);</span><br><span class="line">        dbPrefixList.add(&quot;b&quot;);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line">     * 获取随机的前缀</span><br><span class="line">     *</span><br><span class="line">     * @return</span><br><span class="line">     */</span><br><span class="line">    public static String getRandomDBPrefix(String code) &#123;</span><br><span class="line"></span><br><span class="line">        int hashCode = code.hashCode();</span><br><span class="line"></span><br><span class="line">        int index = Math.abs(hashCode) % dbPrefixList.size();</span><br><span class="line"></span><br><span class="line">        return dbPrefixList.get(index);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>改造后</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line">    * 存储数据库位置编号</span><br><span class="line">    */</span><br><span class="line">   private static final List&lt;String&gt; dbPrefixList = new ArrayList&lt;&gt;();</span><br><span class="line">    //是不是被这种操作惊到了，那就对了，代码很简单主要是思想，这样是新库和老库写入的负载比例是不是就是4:1了</span><br><span class="line">   static &#123;</span><br><span class="line">       dbPrefixList.add(&quot;a&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;b&quot;);</span><br><span class="line"></span><br><span class="line">       dbPrefixList.add(&quot;c&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;d&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;e&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;f&quot;);</span><br><span class="line"></span><br><span class="line">       dbPrefixList.add(&quot;c&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;d&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;e&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;f&quot;);</span><br><span class="line"></span><br><span class="line">       dbPrefixList.add(&quot;c&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;d&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;e&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;f&quot;);</span><br><span class="line">       </span><br><span class="line">       dbPrefixList.add(&quot;c&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;d&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;e&quot;);</span><br><span class="line">       dbPrefixList.add(&quot;f&quot;);</span><br><span class="line">       </span><br><span class="line">       </span><br><span class="line">   &#125;</span><br><span class="line">   /**</span><br><span class="line">    * 获取随机的前缀</span><br><span class="line">    *</span><br><span class="line">    * @return</span><br><span class="line">    */</span><br><span class="line">   public static String getRandomDBPrefix(String code) &#123;</span><br><span class="line"></span><br><span class="line">       int hashCode = code.hashCode();</span><br><span class="line"></span><br><span class="line">       int index = Math.abs(hashCode) % dbPrefixList.size();</span><br><span class="line"></span><br><span class="line">       return dbPrefixList.get(index);</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>

<p>就到这里吧，感谢大佬们的智慧，感谢他们的无私。</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-如何支持更高的并发查询"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/08/02/%E5%A6%82%E4%BD%95%E6%94%AF%E6%8C%81%E6%9B%B4%E9%AB%98%E7%9A%84%E5%B9%B6%E5%8F%91%E6%9F%A5%E8%AF%A2/"
    >如何支持更高的并发查询</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/02/%E5%A6%82%E4%BD%95%E6%94%AF%E6%8C%81%E6%9B%B4%E9%AB%98%E7%9A%84%E5%B9%B6%E5%8F%91%E6%9F%A5%E8%AF%A2/" class="article-date">
  <time datetime="2023-08-02T08:37:02.000Z" itemprop="datePublished">2023-08-02</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>一、今天一个前同事问我如何提高并发查询量，给出了3个选择（硬件和网络环境不变的前提下）</p>
<p>1、http连接池,这个平时也很常见；</p>
<p>2、使用RestTemplate做池化；</p>
<p>3、使用异步+池化；</p>
<p>二、以下按照3点得出测试结论：</p>
<p>测试站点：<a target="_blank" rel="noopener" href="https://www.juhe.cn/_t">https://www.juhe.cn/_t</a></p>
<p>使用jmeter进行压测，参数如下<img src="https://cydmacro.gitee.io/myblog/img/image-20230802165133322.png" alt="image-20230802165133322"></p>
<p>1、httpClient使用4.5，测试结果如下：</p>
<p>没有做连接池等修改,就是一个GET请求</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802164758264.png" alt="image-20230802164758264"></p>
<p>可以看到并发不高，并且有些异常。</p>
<p>2、RestTemplate，测试结果如下：</p>
<p>RestTemplate参数如下：</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802164953590.png" alt="image-20230802164953590"></p>
<p>压测结果</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802165207897.png" alt="image-20230802165207897"></p>
<p>可以看出并发量提高了一些。</p>
<p>3、使用异步+池化测试结果如下：</p>
<p>3.1 阻塞线程获得查询结果:</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802165513921.png" alt="image-20230802165513921"></p>
<p>代码</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802165702672.png" alt="image-20230802165702672"></p>
<p>测试结果</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802165612573.png" alt="image-20230802165612573"></p>
<p>可以看到并发量也不高，主要是因为同步获得了结果了原因。</p>
<p> 3.2 非阻塞线程不获得结果</p>
<p>代码</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802170056541.png" alt="image-20230802170056541"></p>
<p>测试结果</p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230802170122053.png" alt="image-20230802170122053"></p>
<p>三、测试结论</p>
<p>1、从测试结果上看异步+restTemplate池化的并发最高（不同步获得结果）比其他3个高很多；</p>
<p>2、同事说，查询没有结果我查了干什么，说的有道理，我觉得可以在查询的同时做异步存储查询结果，比如存储到ES，mongodb里，然后再做查询，同事说太麻烦了，他们查询的并发量没有那么高，我建议他用restTemplate连接池应该可以得到他的要求。</p>
<p>3、今天正好也复习了一下基础优化思路，其实这些都不重要，还是思路和原理，万变不离其宗；</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-docker安装clicHouse"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/07/28/docker%E5%AE%89%E8%A3%85clicHouse/"
    >docker安装clicHouse</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/07/28/docker%E5%AE%89%E8%A3%85clicHouse/" class="article-date">
  <time datetime="2023-07-28T12:34:59.000Z" itemprop="datePublished">2023-07-28</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://hub.docker.com/r/clickhouse/clickhouse-server/</span><br></pre></td></tr></table></figure>

<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230728203630008.png" alt="image-20230728203630008"></p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230728203659439.png" alt="image-20230728203659439"></p>
<p><img src="https://cydmacro.gitee.io/myblog/img/image-20230728203723118.png" alt="image-20230728203723118"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">docker pull clickhouse/clickhouse-server:latest@sha256:c5f425e56f77a8d99733050cc11a877ee964cfb923eed83bfd1be07b31183de5</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/koutaoran4812/article/details/129000781">https://blog.csdn.net/koutaoran4812/article/details/129000781</a></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">#M1芯片电脑：</span><br><span class="line">docker run -d \ </span><br><span class="line">--name clickhouse-server1 \</span><br><span class="line">--ulimit nofile=262144:262144 \</span><br><span class="line">-v ~/Devlopment/DockerSoft/clickhouse-server1:/var/lib/clickhouse \</span><br><span class="line">-p 9000:9000 -p 8123:8123 -p 9009:9009 \</span><br><span class="line">altinity/clickhouse-server:21.12.3.32.altinitydev.arm</span><br><span class="line"></span><br><span class="line">--注意这里使用自己下载的版本也可使用iamge_id</span><br><span class="line">docker run -d --name clickhouse-server1 --ulimit nofile=262144:262144  -v ~/Devlopment/DockerSoft/clickhouse-server1:/var/lib/clickhouse  -p 9000:9000 -p 8123:8123 -p 9009:9009 clickhouse/clickhouse-server</span><br><span class="line"></span><br><span class="line">--inter芯片</span><br><span class="line">docker run -d </span><br><span class="line">--name clickhouse-server </span><br><span class="line">--ulimit nofile=262144:262144 </span><br><span class="line">-p 9000:9000 -p 8123:8123 -p 9009:9009 </span><br></pre></td></tr></table></figure>



 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
  </article>
  

  
  <nav class="page-nav">
    
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/2/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2023
        <i class="ri-heart-fill heart_icon"></i> cyd
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="风舞神者"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="http://shenyu-vip.lofter.com">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>